<template>
	<view class="community">
		<view class="top">
			<uv-navbar title="师傅列表" bgColor="#65c9bb" height="66px" titleStyle="{font-weight: bold;font-size: 1.1rem;}"
				@click="goback"></uv-navbar>
		</view>
		<!-- 选项卡 -->
		<view class="tabs">
			<uv-tabs :list="list" lineColor="#149494" activeStyle=" color:#149494" :scrollable="false"
				@click="click"></uv-tabs>
		</view>

		<!-- 综合 -->
		<view v-if="current== 0">
			<view class="avatar">
				<view class="recommend" >
					<view class="recommend-bottom1">
						<view class="bottom-top1"  @click="gomaster(item.id)" v-for="item in DistanceList" :key="item.id">
							<view class="photo">
								<image class="image2" :src="item.image" mode=""></image>
								<view class="shadow">上次服务</view>
							</view>
							<view class="text1">{{item.name}}</view>
							<view class="text2">已服务:{{item.num}}次</view>
						</view>
					</view>
				</view>
			</view>
		</view>

		<!-- 距离 -->
		<view v-if="current== 1">
			<view class="avatar">
				<view class="recommend">
					<view class="recommend-bottom1">
						<view class="bottom-top1"  @click="gomaster(item.id)" v-for="item in ComprehensiveList" :key="item.id">
							<view class="photo">
								<image class="image2" :src="item.image" mode=""></image>
								<view class="shadow">上次服务</view>
							</view>
							<view class="text1">{{item.name}}</view>
							<view class="text2">已服务:{{item.num}}次</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<!-- 服务次数 -->
		<view v-if="current== 2">
			<view class="avatar">
				<view class="recommend">
					<view class="recommend-bottom1">
						<view class="bottom-top1"  @click="gomaster(item.id)" v-for="item in ServiceTimes" :key="item.id">
							<view class="photo">
								<image class="image2" :src="item.image" mode=""></image>
								<view class="shadow">上次服务</view>
							</view>
							<view class="text1">{{item.name}}</view>
							<view class="text2">已服务:{{item.num}}次</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<!-- 好评 -->
		<view v-if="current== 3">
			<view class="avatar">
				<view class="recommend">
					<view class="recommend-bottom1">
						<view class="bottom-top1"  @click="gomaster(item.id)" v-for="item in Comments" :key="item.id">
							<view class="photo">
								<image class="image2" :src="item.image" mode=""></image>
								<view class="shadow">上次服务</view>
							</view>
							<view class="text1">{{item.name}}</view>
							<view class="text2">已服务:{{item.num}}次</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		myRequest
	} from '@/request/request.js'
	export default {
		data() {
			return {
				// 综合列表
				ComprehensiveList: '',
				// 距离列表
				DistanceList: '',
				// 服务次数
				ServiceTimes:'',
				// 好评
				Comments:'',
				current: '',
				list: [{
					name: '综合',
				}, {
					name: '距离',
				}, {
					name: '服务次数',
				}, {
					name: '好评',
				}]
			}
		},
		onLoad() {
			// 师傅综合
			const that = this
			myRequest('master/list1?server=1', function(err, data) {
				if (err) {
					uni.showToast({
						title: err,
					});
				} else {
					that.ComprehensiveList = data.data.list
					// console.log("成功", that.ComprehensiveList);
				}
			}, 'GET', {

			})
			// 距离列表
			myRequest('master/list2?server=1', function(err, data) {
				if (err) {
					uni.showToast({
						title: err,
					});
				} else {
					that.DistanceList = data.data.list
					// console.log("距离", that.DistanceList);
				}
			}, 'GET', {

			})
			// 服务次数
			myRequest('master/list3?server=1', function(err, data) {
				if (err) {
					uni.showToast({
						title: err,
					});
				} else {
					that.ServiceTimes = data.data.list
					// console.log("服务", that.DistanceList);
				}
			}, 'GET', {
			
			})
			// 好评
			myRequest('master/list4?server=1', function(err, data) {
				if (err) {
					uni.showToast({
						title: err,
					});
				} else {
					that.Comments = data.data.list
					// console.log("服务", that.DistanceList);
				}
			}, 'GET', {
			
			})
		},
		methods: {
			// 跳转师傅推荐
			gomaster(id) {
				console.log(id);
				 
				uni.navigateTo({
					url: `/pages/masterdetails/masterdetails?id=${JSON.stringify(id)}`
				})
			},
			goback() {
				uni.navigateBack({
					delta: 1
				});
			},
			click(item) {
				this.current = item.index
				console.log('item', item.index);
			}
		}
	}
</script>

<style lang="scss">
	@import url("listmasters.scss");
</style>